package br.ufal.tci.nexos.arcolive.beans;

import br.ufal.tci.nexos.arcolive.beans.ArCoLIVEParticipant;
import java.awt.Image;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.beans.SimpleBeanInfo;

/**
 * @author <a href="mailto:felipe@labpesquisas.tci.ufal.br">Felipe Barros Pontes</a>.
 * @author <a href="mailto:leandro@labpesquisas.tci.ufal.br">Leandro Melo de
 *         Sales</a>.
 */
public class ParticipantBeanInfo extends SimpleBeanInfo {

	private final static Class arcoliveParticipantClass = ArCoLIVEParticipant.class;

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.beans.BeanInfo#getIcon(int)
	 */
	public Image getIcon(int type) {
		String name = "";
		if (type == BeanInfo.ICON_COLOR_16x16) {
			name = "COLOR_16x16";
		} else if (type == BeanInfo.ICON_COLOR_32x32) {
			name = "COLOR_32x32";
		} else if (type == BeanInfo.ICON_MONO_16x16) {
			name = "MONO_16x16";
		} else if (type == BeanInfo.ICON_MONO_32x32) {
			name = "MONO_32x32";
		} else {
			return null;
		}
		return loadImage("ArCoLIVEParticipant_" + name + ".jpg");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.beans.BeanInfo#getPropertyDescriptors()
	 */
	public PropertyDescriptor[] getPropertyDescriptors() {
		try {
			PropertyDescriptor name = new PropertyDescriptor("name",
					arcoliveParticipantClass);
			name.setDisplayName("Partipant's name");
			name.setBound(true);
			PropertyDescriptor email = new PropertyDescriptor("email",
					arcoliveParticipantClass);
			email.setDisplayName("Partipant's email");
			email.setBound(true);
			PropertyDescriptor login = new PropertyDescriptor("login",
					arcoliveParticipantClass);
			login.setDisplayName("Partipant's login");
			login.setBound(true);
			PropertyDescriptor post = new PropertyDescriptor("post",
					arcoliveParticipantClass);
			post.setDisplayName("Partipant's post");
			post.setBound(true);
			post.setPropertyEditorClass(ParticipantRolePropertyEditor.class);
			PropertyDescriptor[] propertyDescriptors = new PropertyDescriptor[] {
					name, email, login, post };
			return propertyDescriptors;
		} catch (IntrospectionException e) {
			e.printStackTrace();
			return null;
		}
	}

}